package com.itguigu.rabbitmq.utils;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @Date 2021/7/18 10:55
 * @Created by wangle
 * @Description 连接工厂创建信道的工具类
 */
public class RabbitMqutil {

    public static Channel getChannel() throws IOException, TimeoutException {

        //创建一个连接工厂
        ConnectionFactory factory = new ConnectionFactory();
        //创建工厂ip ，连接rabbitmq的对列
        factory.setHost("192.168.245.133");
        //用户名
        factory.setUsername("admin");
        //密码
        factory.setPassword("admin");

        //创建连接
        Connection connection = factory.newConnection();
        //获取信道
        Channel channel = connection.createChannel();

        return channel;


    }


}
